local M = require "packages/mamashengde/record/Made"

local moli = fk.CreateSkill {
  name = "lvlingqi__moli",
  tags = { M.HenshinSkill },
}

Fk:loadTranslationTable {
  ["lvlingqi__moli"] = "魔力",
  [":lvlingqi__moli"] = "<a href='#made_henshin_skill'><font color='pink'>变身技</font></a>（0/5），游戏开始时或当你造成1点伤害时，你获得1点魔力；"..
  "准备阶段，你<a href='lvlingqi__Henshin'><font color='pink'>进行吟唱并变身</font></a>。",
  ["lvlingqi__Henshin"] = "在对应的时机点，若你的魔力已达上限，你可以吟唱咒语并变身为闪耀战姬！<br>" ..
  "<b>恒辉</b>：锁定技，当你变身后，你获得任意个效果并消耗等量的魔力：1.使用【杀】的次数和造成的伤害+1；" ..
  "2.【杀】无距离限制且目标数+2；3.摸五张牌并弃置装备区内的所有牌。<br>" ..
  "<b>魔契</b>：每次变身限一次，出牌阶段，你可以消耗至少3点魔力并失去所有体力，然后你令“恒辉”的所有数值翻倍。" ..
  "若如此做，你保持变身状态直到结束阶段。",

  ["$lvlingqi__moli1"] = "Starlight Ascension！", -- 吟唱
  ["$lvlingqi__moli2"] = "Starlight Ascension！",
}

moli:addEffect(fk.GameStart, {
  mute = true,
  can_trigger = function(self, event, target, player, data)
    return  player:hasSkill(moli.name) and M.getMaryoku(player) < M.getMaryokuMax(player)
  end,
  on_cost = Util.TrueFunc,
  on_use = function(self, event, target, player, data)
    M.changeMaryoku(player, 1, moli.name)
  end,
})

moli:addEffect(fk.DamageCaused, {
  mute = true,
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(moli.name) and M.getMaryoku(player) < M.getMaryokuMax(player)
  end,
  on_cost = Util.TrueFunc,
  on_use = function(self, event, target, player, data)
    M.changeMaryoku(player, data.damage, moli.name)
  end,
})

moli:addEffect(fk.EventPhaseStart, {
  anim_type = "big",
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(moli.name) and
      player.phase == Player.Start and
      M.getMaryoku(player) >= M.getMaryokuMax(player) and
      player.general == "shine__lvlingqi"
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local target_general = "shine2__lvlingqi" -- 目标武将
    if M.enterHenshin(player, target_general, moli.name) then
        -- 变身成功后的处理
        room:notifySkillInvoked(player, moli.name, "positive")
    end
  end,
})

moli:addAcquireEffect(function (self, player)
  if M.getMaryokuMax(player) == 0 then
    M.setMaryokuMax(player, 5, moli.name)
  end
end)

return moli